#include <gtest/gtest.h>
#include <iostream>
#include <unordered_map>
#include <string>

class HashTestEnv : public testing::Test
{
    public:
    static void SetUpTestCase()
    {
        std::cout << "第一个单元测试开始之前调用，初始化总环境" << std::endl;
    }
    static void TearDownTestCase()
    {
        std::cout << "最后一个单元测试完成后，清理总环境" << std::endl;
    }

    virtual void SetUp() override
    {
        std::cout << "每一个单元测试开始之前调用，准备数据" << std::endl;
        _dict.insert({"haha", "哈哈"});
        _dict.insert({"byebye", "拜拜"});
    }

    virtual void TearDown() override
    {
        std::cout << "每一个单元测试结束后调用，清理数据" << std::endl;
        _dict.clear();
    }
public:
    std::unordered_map<std::string, std::string> _dict;
};

TEST_F(HashTestEnv, insert_test)
{
    _dict.insert({"hello", "你好"});
    ASSERT_EQ(_dict.size(), 3);
}

TEST_F(HashTestEnv, size_test)
{
    ASSERT_EQ(_dict.size(), 2);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    RUN_ALL_TESTS();
    return 0;
}